package com.saga.energy.sink;

import com.alibaba.fastjson.JSONArray;
import com.saga.energy.bean.UserToSpace;
import com.saga.energy.util.SysConstant;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.shaded.guava18.com.google.common.collect.Lists;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ZJSpaceToMysql2 extends RichSinkFunction<JSONArray> {

    private PreparedStatement ps;
    private Connection conn;

    private Map<String, List<String>> roomMap = new HashMap<>();

    private List<String> userIds = new ArrayList<>();

    private void initMap(){
        roomMap.put("24104791",Lists.newArrayList("4-5-C535","Sp3301100002e03c916187884dc7849185c5815a0418"));
//        roomMap.put("24104791",Lists.newArrayList("4-5-C535b","Sp3301100002e122ec2ab2274ad795126174e5f3fc0a"));
        roomMap.put("24104789",Lists.newArrayList("4-5-C533","Sp3301100002d34c338db78e4bf78da727add2636b56"));
//        roomMap.put("24104789",Lists.newArrayList("4-5-C533b","Sp3301100002d962551004af43fba83b0c97ebbb8e3e"));
        roomMap.put("24104788",Lists.newArrayList("4-5-C532","Sp3301100002d1f595c215b24a19ae5f328a5a70386f"));
//        roomMap.put("24104788",Lists.newArrayList("4-5-C532b","Sp3301100002d344a16a60ce4a6ba554fa9a12bcb8cc"));
        roomMap.put("24104787",Lists.newArrayList("4-5-C531","Sp3301100002c68ae137a5bb427d92ad31f66ed09034"));
//        roomMap.put("24104787",Lists.newArrayList("4-5-C531b","Sp3301100002cf7ba92adf464334aed0d5de5b902098"));
        roomMap.put("24104763",Lists.newArrayList("4-5-C505","Sp33011000028c8bdd5617b64fce9513bfcdcb928342"));
//        roomMap.put("24104763",Lists.newArrayList("4-5-C505b","Sp33011000028ccf1b03f35e4f8e8b7628d15c8cec47"));
        roomMap.put("24104762",Lists.newArrayList("4-5-C503","Sp33011000028aa7d44f707a4427939c06d6716ce900"));
//        roomMap.put("24104762",Lists.newArrayList("4-5-C503b","Sp33011000028b15359c17784871876febce7ff8949b"));
        roomMap.put("24104719",Lists.newArrayList("4-4-C403","Sp330110000224d5271251624217bb0887d834ff27bd"));
//        roomMap.put("24104719",Lists.newArrayList("4-4-C403b","Sp3301100002255e8a62f1b941bb8dec44adf9786b80"));
        roomMap.put("23820203",Lists.newArrayList("1-13-1325-1","Sp330110000235acd7dee5eb480c8e3a7ab65feed307"));
//        roomMap.put("23820203",Lists.newArrayList("1-13-1325-2","Sp330110000235c239adff2d4de7b8a9014fe2e32f1e"));
        roomMap.put("23820182",Lists.newArrayList("1-13-1301-1","Sp3301100002215425ca775e4d458447980f0f97a760"));
//        roomMap.put("23820182",Lists.newArrayList("1-13-1301-2","Sp33011000023239a1878a1e4876aee87c9cd461b70b"));
        roomMap.put("23820153",Lists.newArrayList("1-12-1201-1","Sp330110000211bb717cf8e944e4aa44a745bcc597fb"));
//        roomMap.put("23820153",Lists.newArrayList("1-12-1201-2","Sp3301100002175d1db99d064c4b9e22ed2b161c80ce"));
        roomMap.put("23820145",Lists.newArrayList("1-11-1125-1","Sp33011000025e23ebeb669040c6b1c6df19aab6e5f3"));
//        roomMap.put("23820145",Lists.newArrayList("1-11-1125-2","Sp33011000025e34fa77886a4023a78f98bf07555609"));

    }
    private void initMap1(){
        roomMap.put("24103952",Lists.newArrayList("8-5-L502","Sp33011000028eb2e149c0e94db09c740409fce8c143"));
        roomMap.put("24103949",Lists.newArrayList("8-5-L501-07","Sp330110000264e83aeb3cd849419348cf26a40c2845"));
        roomMap.put("24103945",Lists.newArrayList("8-5-L501-03","Sp3301100002616c3075af8f458880c5f868c2e99652"));
        roomMap.put("24103944",Lists.newArrayList("8-5-L501-02","Sp3301100002604d39d66c8640e4bfd21f872597d324"));
        roomMap.put("24103943",Lists.newArrayList("8-5-L501-01","Sp330110000258e172f051d9406db243820b6804adca"));
        roomMap.put("24103942",Lists.newArrayList("8-5-L501","Sp33011000025170469d63774005a1cd9f6dae972875"));
        roomMap.put("918996547156578304",Lists.newArrayList("8-5-L501","Sp33011000025170469d63774005a1cd9f6dae972875"));
        roomMap.put("24103933",Lists.newArrayList("8-4-L401-06","Sp3301100002b660941b91de4ae09c0cb2beb38ae4ce"));
        roomMap.put("24103930",Lists.newArrayList("8-4-L401-03","Sp3301100002b3fb9db5fb3644ceb05ab235863981d0"));
        roomMap.put("24104791",Lists.newArrayList("4-5-C535","Sp3301100002e03c916187884dc7849185c5815a0418"));
        roomMap.put("24104791",Lists.newArrayList("4-5-C535b","Sp3301100002e122ec2ab2274ad795126174e5f3fc0a"));
        roomMap.put("24104789",Lists.newArrayList("4-5-C533","Sp3301100002d34c338db78e4bf78da727add2636b56"));
        roomMap.put("24104789",Lists.newArrayList("4-5-C533b","Sp3301100002d962551004af43fba83b0c97ebbb8e3e"));
        roomMap.put("24104788",Lists.newArrayList("4-5-C532","Sp3301100002d1f595c215b24a19ae5f328a5a70386f"));
        roomMap.put("24104788",Lists.newArrayList("4-5-C532b","Sp3301100002d344a16a60ce4a6ba554fa9a12bcb8cc"));
        roomMap.put("24104787",Lists.newArrayList("4-5-C531","Sp3301100002c68ae137a5bb427d92ad31f66ed09034"));
        roomMap.put("24104787",Lists.newArrayList("4-5-C531b","Sp3301100002cf7ba92adf464334aed0d5de5b902098"));
        roomMap.put("24104783",Lists.newArrayList("4-5-C527","Sp3301100002b230ee63b7de4e2c9110fcc7446c3d4d"));
        roomMap.put("24104782",Lists.newArrayList("4-5-C526","Sp3301100002b131fa3c6fa34a5c9cc30483c55e53e6"));
        roomMap.put("24104779",Lists.newArrayList("4-5-C522","Sp3301100002aa8766d525ec415d9bef522c0451fcc2"));
        roomMap.put("24104778",Lists.newArrayList("4-5-C521","Sp3301100002a89715a7a33247abaa967b457ea7e59c"));
        roomMap.put("24104777",Lists.newArrayList("4-5-C520","Sp3301100002a75e875e32a74d0fa994ffa49a46600f"));
        roomMap.put("24104767",Lists.newArrayList("4-5-C509","Sp3301100002933975e007224a34a94090837eb46d94"));
        roomMap.put("24104765",Lists.newArrayList("4-5-C507","Sp3301100002908523447541401596737a89ae909853"));
        roomMap.put("24104764",Lists.newArrayList("4-5-C506","Sp33011000028dcf8cc1f7aa41d2947c591a19ddea91"));
        roomMap.put("24104763",Lists.newArrayList("4-5-C505","Sp33011000028c8bdd5617b64fce9513bfcdcb928342"));
        roomMap.put("24104763",Lists.newArrayList("4-5-C505b","Sp33011000028ccf1b03f35e4f8e8b7628d15c8cec47"));
        roomMap.put("24104762",Lists.newArrayList("4-5-C503","Sp33011000028aa7d44f707a4427939c06d6716ce900"));
        roomMap.put("24104762",Lists.newArrayList("4-5-C503b","Sp33011000028b15359c17784871876febce7ff8949b"));
        roomMap.put("24104761",Lists.newArrayList("4-5-C502","Sp33011000028a36062f0b7446fe8536ee621805869f"));
        roomMap.put("24104760",Lists.newArrayList("4-5-C501","Sp330110000287dedcdf41c54997ae932efa8a80369c"));
        roomMap.put("24104723",Lists.newArrayList("4-4-C408","Sp33011000022c81b0dce1624d17914988c929d916fa"));
        roomMap.put("928322647565275136",Lists.newArrayList("4-4-C407","Sp33011000022791d988f80c46eeb71c00ca252a7b03"));
        roomMap.put("24104722",Lists.newArrayList("4-4-C407","Sp33011000022791d988f80c46eeb71c00ca252a7b03"));
        roomMap.put("24104721",Lists.newArrayList("4-4-C406","Sp3301100002276460d008ab49d09bb865ee17b310fb"));
        roomMap.put("24104720",Lists.newArrayList("4-4-C405","Sp330110000226c23770b1c74a41a070a1dc1b23abc8"));
        roomMap.put("24104719",Lists.newArrayList("4-4-C403","Sp330110000224d5271251624217bb0887d834ff27bd"));
        roomMap.put("24104719",Lists.newArrayList("4-4-C403b","Sp3301100002255e8a62f1b941bb8dec44adf9786b80"));
        roomMap.put("24104752",Lists.newArrayList("4-5-B513","Sp33011000026e4eabf8c0d045c788dd2fbe3134d1ca"));
        roomMap.put("24104750",Lists.newArrayList("4-5-B511","Sp33011000026ce53655322d4f709b3a33765dd71a28"));
        roomMap.put("24104749",Lists.newArrayList("4-5-B510","Sp33011000026c806fd2d79d4302a35a01c4ca1ec1f4"));
        roomMap.put("24104748",Lists.newArrayList("4-5-B509","Sp330110000263ee0d16d5364b569aa1d47bd38d6967"));
        roomMap.put("24104747",Lists.newArrayList("4-5-B508","Sp3301100002626b8b84a38840ddbf2b110de3b49359"));
        roomMap.put("24104746",Lists.newArrayList("4-5-B507","Sp330110000262013c14e16548a39fadd3ae5f4612ec"));
        roomMap.put("918902404795338752",Lists.newArrayList("7-5-B506-02","Sp330110000226f3ddd8f7f64ff28e87a18643f2b0e8"));
        roomMap.put("24104745",Lists.newArrayList("4-5-B506","Sp33011000025dc0fd3481b949dc95f25b0f7b85f3f8"));
        roomMap.put("24104744",Lists.newArrayList("4-5-B505","Sp3301100002585723d7f7da4e0f8e5d04b7abbed2b4"));
        roomMap.put("918997813018497024",Lists.newArrayList("8-5-B501","Sp3301100002045ddaf3b0c04076bd0c6e0a28d74d68"));
        roomMap.put("24104715",Lists.newArrayList("4-4-B419","Sp3301100002bd27b2536cab41a595174c77233d2808"));
        roomMap.put("24104714",Lists.newArrayList("4-4-B418","Sp3301100002b0858ca3ff7a4f37a25326317a67fbc9"));
        roomMap.put("24104713",Lists.newArrayList("4-4-B417","Sp3301100002af3e1b9e3e564f0baa490fdd2de3e9e2"));
        roomMap.put("24104711",Lists.newArrayList("4-4-B415","Sp3301100002ae1b2384d1c64c4f9bb1c3f1bd87b1ad"));
        roomMap.put("23820445",Lists.newArrayList("7-4-B413","Sp3301100002798ab4a02f314469b7252281585d19fa"));
        roomMap.put("23820442",Lists.newArrayList("7-4-B410","Sp3301100002626a94926e724b0187502aa53f765bf9"));
        roomMap.put("24104707",Lists.newArrayList("4-4-B410","Sp330110000296e292c1bd7d44f39cb4fe784798955e"));
        roomMap.put("23820441",Lists.newArrayList("7-4-B409","Sp33011000025a0e0e11519941e59898c02501fff8e4"));
        roomMap.put("24104706",Lists.newArrayList("4-4-B409","Sp33011000028d8fbbd7a16e448b932d0dfcffa23b6d"));
        roomMap.put("24104705",Lists.newArrayList("4-4-B408","Sp33011000028d56d87c7bfe40609237bb3fc4f70624"));
        roomMap.put("23820440",Lists.newArrayList("7-4-B408","Sp330110000258be501c0d02437b8f5e5244fb9dac44"));
        roomMap.put("920041004123557888",Lists.newArrayList("11-4-B405","Sp33011000021df8f881eec1451eb90c62314d8b9c4e"));
        roomMap.put("920040585683013632",Lists.newArrayList("11-4-B402-05","Sp330110000216783433dea9493b9ed98f1fbc17cc1b"));
        roomMap.put("920040130248708096",Lists.newArrayList("11-4-B402-01","Sp33011000020942304a562344af85df2b36497daab8"));
        roomMap.put("24104700",Lists.newArrayList("4-4-B402","Sp33011000027a39d9456f444d72b538316c439fb921"));
        roomMap.put("920039879811010560",Lists.newArrayList("11-4-B402","Sp3301100002072d1dd3ff4642bbbf0e6720c2eee7e8"));
        roomMap.put("920035254898790400",Lists.newArrayList("11-4-B401-07","Sp3301100002ec2a7ad5497e45a0904476a471539a33"));
        roomMap.put("24104277",Lists.newArrayList("2-3-B313","Sp330110000282e85fe7a48648959e97d736a3ea9e84"));
        roomMap.put("24104273",Lists.newArrayList("2-3-B309","Sp33011000026003995ce6194c32922cc1efa4999807"));
        roomMap.put("24104271",Lists.newArrayList("2-3-B307","Sp33011000025bc4eeade1e44a30952f57d48ce1d1af"));
        roomMap.put("24104270",Lists.newArrayList("2-3-B306","Sp3301100002597c9c4d64814ed598ff22e1e25d6360"));
        roomMap.put("24104269",Lists.newArrayList("2-3-B305","Sp330110000257743708f0994c74a08849a9f90942a7"));
        roomMap.put("890172664601382912",Lists.newArrayList("11-3-B303-05","Sp3301100002614261cd347b409d8f4218b44ae248ed"));
        roomMap.put("890172364842864640",Lists.newArrayList("11-3-B303-01","Sp3301100002584fe961f778495394090e488dd2af31"));
        roomMap.put("890172252611678208",Lists.newArrayList("11-3-B303","Sp330110000256d24d6a59b546bc8d0bc04d11154ae7"));
        roomMap.put("24104267",Lists.newArrayList("2-3-B303","Sp330110000251436495a65d4710b5a131c4e7e07618"));
        roomMap.put("890172045400477696",Lists.newArrayList("11-3-B302-07","Sp330110000254712dd6593047eb9ed4bc3755f67c51"));
        roomMap.put("890171070497427456",Lists.newArrayList("11-3-B302-06","Sp33011000024bf21792d92545fbacffef433f008b00"));
        roomMap.put("890170584755081216",Lists.newArrayList("11-3-B302","Sp330110000230d0527884d94567b0658365ff85a21b"));
        roomMap.put("24104265",Lists.newArrayList("2-3-B301","Sp33011000023d94f1d149df42acacd6663b3058de22"));
        roomMap.put("24104237",Lists.newArrayList("2-2-B207","Sp33011000024dc1f47d18b74024868f7b3bd7f628d7"));
        roomMap.put("24104235",Lists.newArrayList("2-2-B205","Sp330110000245aae75c04f84236bcd99a91a53a2fb5"));
        roomMap.put("890168441654480896",Lists.newArrayList("11-2-B201","Sp3301100002523f850201d3496981554522ea04b9f4"));
        roomMap.put("24103940",Lists.newArrayList("8-5-A501","Sp3301100002005804edfa2c4f9ca19bfc462f92be49"));
        roomMap.put("918989826187071488",Lists.newArrayList("8-4-A416-02","Sp330110000237486634c9e94ac5bfc7cd921166a7a1"));
        roomMap.put("918990671255441408",Lists.newArrayList("8-4-A415-05","Sp33011000022ba65b15d6fe4c14a8df803ab9921977"));
        roomMap.put("918990464287510528",Lists.newArrayList("8-4-A415-02","Sp330110000223d012df17dc467ca1eb4fdf54294bcd"));
        roomMap.put("918990336981995520",Lists.newArrayList("8-4-A415-01","Sp33011000022306e712fed342369138be8b74403d33"));
        roomMap.put("23820431",Lists.newArrayList("7-4-A413","Sp330110000234543f9562c34b9db81f8d6273b2f255"));
        roomMap.put("24103920",Lists.newArrayList("8-4-A409","Sp330110000216f604a97dff47fcbf1c6946aa21ad3f"));
        roomMap.put("24103915",Lists.newArrayList("8-4-A403-02","Sp330110000209c523da585045beb79cdced203d022e"));
        roomMap.put("24103900",Lists.newArrayList("8-3-A322","Sp33011000024b99fa2cf4da4036ac9f87e52976a880"));
        roomMap.put("24103899",Lists.newArrayList("8-3-A321","Sp330110000249310c52a3a44bc68fca5bf6fef5b429"));
        roomMap.put("23820410",Lists.newArrayList("7-3-A321","Sp330110000277a12670291b4532aa7e24228a5eaf35"));
        roomMap.put("23820409",Lists.newArrayList("7-3-A320","Sp330110000274bdc0647e444310b35f9e1e9b972d32"));
        roomMap.put("23820408",Lists.newArrayList("7-3-A319","Sp33011000027180009804da474c95a0d34ef5d164d1"));
        roomMap.put("24103896",Lists.newArrayList("8-3-A318","Sp330110000245393fdd941149348a58a67a8b4be7ba"));
        roomMap.put("23820406",Lists.newArrayList("7-3-A317","Sp33011000026dd5132aab4548cca51605dda48e47b5"));
        roomMap.put("23820404",Lists.newArrayList("7-3-A315","Sp330110000265390e0339234ba193c5bf096c07ed23"));
        roomMap.put("24104262",Lists.newArrayList("2-3-A315","Sp33011000020b33f86aae4048fea45c7d37bd94826f"));
        roomMap.put("24104260",Lists.newArrayList("2-3-A313","Sp33011000020a6e7f890c3146428d08ab607467667a"));
        roomMap.put("23820403",Lists.newArrayList("7-3-A313","Sp33011000025c8d9f4daa854d90bdb83136f5b3acdc"));
        roomMap.put("24104258",Lists.newArrayList("2-3-A311","Sp3301100002004c52b4385140998f1a74cc550fba51"));
        roomMap.put("23820400",Lists.newArrayList("7-3-A310","Sp33011000023c88a07034e34454bd9f540f510a9797"));
        roomMap.put("918878482360176640",Lists.newArrayList("7-3-A310","Sp33011000023c88a07034e34454bd9f540f510a9797"));
        roomMap.put("918877773090787328",Lists.newArrayList("7-3-A310","Sp33011000023c88a07034e34454bd9f540f510a9797"));
        roomMap.put("24103889",Lists.newArrayList("8-3-A310","Sp33011000021fd195c2c0614eb492faa1b9f3df4be5"));
        roomMap.put("24104256",Lists.newArrayList("2-3-A309","Sp33011000029b0fe3cbb2e44d53a0acbda33442f987"));
        roomMap.put("24103887",Lists.newArrayList("8-3-A308","Sp33011000021f6440b510904c178cc2846499ae323a"));
        roomMap.put("24104254",Lists.newArrayList("2-3-A307","Sp330110000285ac80a1c0c24d9a9087860764f6bbfb"));
        roomMap.put("24104250",Lists.newArrayList("2-3-A303","Sp33011000027372da3e99cf4cce967551e17a4a3dc6"));
        roomMap.put("24103878",Lists.newArrayList("8-3-A301","Sp330110000200422b16aa4f44a9b1bfb56779a44dac"));
        roomMap.put("23820392",Lists.newArrayList("7-3-A301","Sp330110000200fbaf44034149abac268dbe38c850c3"));
        roomMap.put("24104248",Lists.newArrayList("2-3-A301","Sp3301100002280b81f514d3402d9970f8839b458fe2"));
        roomMap.put("24103875",Lists.newArrayList("8-2-A222","Sp33011000024bc639375e10485aa93a1c82715ea881"));
        roomMap.put("24103874",Lists.newArrayList("8-2-A221","Sp33011000024a006c51b8ea4a1bafbeefff868e355d"));
        roomMap.put("24103873",Lists.newArrayList("8-2-A220","Sp330110000247e11794e2754d3b997540fb4242ae80"));
        roomMap.put("24103872",Lists.newArrayList("8-2-A219","Sp3301100002448d169a9d864ce7a3950e19eacdb7c5"));
        roomMap.put("24103871",Lists.newArrayList("8-2-A218","Sp33011000023c712eca68524b25a12fe1c6a31e458a"));
        roomMap.put("24103870",Lists.newArrayList("8-2-A217","Sp33011000023c144780326f449fb6712f7fc0693292"));
        roomMap.put("24103869",Lists.newArrayList("8-2-A216","Sp330110000237db7c65bd2a4de6bad2f78a57c2b002"));
        roomMap.put("24103868",Lists.newArrayList("8-2-A215","Sp33011000023111a0ab67fb4a428934f02d72d4b9b8"));
        roomMap.put("24103867",Lists.newArrayList("8-2-A213","Sp3301100002227db375c8614f88945f3c74a4cef713"));
        roomMap.put("24103866",Lists.newArrayList("8-2-A212","Sp33011000022223dd0e44ef4d9c9428649161ffb389"));
        roomMap.put("24103865",Lists.newArrayList("8-2-A210","Sp33011000021d678dbb0bee4605b91ee9454d3e7688"));
        roomMap.put("24103863",Lists.newArrayList("8-2-A209","Sp33011000021c1e083cacb943c4845d7072ea0d9be3"));
        roomMap.put("24103860",Lists.newArrayList("8-2-A206","Sp33011000020f75909f761841a8851ae1af9c5778e6"));
        roomMap.put("24103859",Lists.newArrayList("8-2-A205","Sp33011000020b1ceba2e0534fd7b854b5522b87900b"));
        roomMap.put("24103856",Lists.newArrayList("8-2-A201-03","Sp3301100002050a5880f7784d6abd11abc4777873ea"));
        roomMap.put("24103853",Lists.newArrayList("8-2-A201","Sp3301100002006e34649fcf49eb8f7a1dca3a59c163"));
        roomMap.put("24103851",Lists.newArrayList("8-1-A117","Sp33011000022f4d92628eba4e058ac2b1d490911edc"));
        roomMap.put("24103849",Lists.newArrayList("8-1-A115","Sp330110000215f87da57e464ca18743e9254c8caed2"));
        roomMap.put("24103848",Lists.newArrayList("8-1-A113","Sp33011000020efead05140c4d3fa4044281a2c3a74e"));
        roomMap.put("24103843",Lists.newArrayList("8-1-A108","Sp3301100002ae82c84ba4ab44fda0f093df1b295c86"));
        roomMap.put("24103842",Lists.newArrayList("8-1-A107","Sp3301100002a604d338aebd4eea81177fe05a15f9c0"));
        roomMap.put("24105240",Lists.newArrayList("6-4-438","Sp3301100002b215eebb08e74769ba3bc531841dee63"));
        roomMap.put("24105238",Lists.newArrayList("6-4-436","Sp3301100002a362abff798447e78614a993c5a3c17f"));
        roomMap.put("24105236",Lists.newArrayList("6-4-433","Sp3301100002965accb38e6d4f3d8ac1434c22f7b355"));
        roomMap.put("24105235",Lists.newArrayList("6-4-432","Sp33011000028a5c9f600bde44498cc96be350cadce8"));
        roomMap.put("24105234",Lists.newArrayList("6-4-431","Sp3301100002851a63ea8f234f32830a5b207f3fec45"));
        roomMap.put("24105232",Lists.newArrayList("6-4-429","Sp33011000027af691ed03ef4de2b4012d1faa397bc2"));
        roomMap.put("24105231",Lists.newArrayList("6-4-428","Sp3301100002790b763403184218a3be98a76dfbf962"));
        roomMap.put("24105230",Lists.newArrayList("6-4-427","Sp330110000271a43b246f53480685077213dd2755c3"));
        roomMap.put("24105227",Lists.newArrayList("6-4-423","Sp330110000255a9348a8d2c4d909fcc3253897ea438"));
        roomMap.put("24105226",Lists.newArrayList("6-4-422","Sp330110000253fd81333b574f35a28ab10ec8ce9fe2"));
        roomMap.put("24105221",Lists.newArrayList("6-4-417","Sp330110000242206594b1a9495fa6a579a3b34d4216"));
        roomMap.put("24105219",Lists.newArrayList("6-4-415","Sp33011000023a5ac5709b164213aacaaf0494095cfb"));
        roomMap.put("24105217",Lists.newArrayList("6-4-412","Sp33011000022ddcc1c770044aabaa5c09e7d9450005"));
        roomMap.put("24105216",Lists.newArrayList("6-4-411","Sp330110000227acfebbbd2e42c68b4f0df200a3631e"));
        roomMap.put("24105214",Lists.newArrayList("6-4-409","Sp3301100002231a8b6fbc1d4efcba8df8ff2ca2d9c4"));
        roomMap.put("24105213",Lists.newArrayList("6-4-408","Sp33011000021d2c58f155244f3fa5828ebdfff153f6"));
        roomMap.put("24105212",Lists.newArrayList("6-4-407","Sp33011000021ae4263af7bf41b5a5922f39e3e075ed"));
        roomMap.put("24105211",Lists.newArrayList("6-4-406","Sp33011000021716c1142dac4e458f60ac8650a5dec4"));
        roomMap.put("24105209",Lists.newArrayList("6-4-403","Sp3301100002095b1723e15d4a12add92a1ba3502f47"));
        roomMap.put("24105208",Lists.newArrayList("6-4-402","Sp330110000207fc9c664f764c54b31573ebca48d82f"));
        roomMap.put("24105207",Lists.newArrayList("6-4-401","Sp3301100002054d5a48c964489cbac83019544f690d"));
        roomMap.put("23820112",Lists.newArrayList("1-2F-225","Sp3301100002115e015221654a6db1772fc91be03205"));
        roomMap.put("23820111",Lists.newArrayList("1-2F-223","Sp33011000020f65354d57e64a908c26a83354d0983b"));
        roomMap.put("23820285",Lists.newArrayList("1-16-1632","Sp3301100002a88038f859a840538c94386194fab227"));
        roomMap.put("23820282",Lists.newArrayList("1-16-1629","Sp3301100002a5c3b8e52dd548c7837633b4fdce3f69"));
        roomMap.put("23820281",Lists.newArrayList("1-16-1628","Sp3301100002a4a3b6fbbcce407cbcfc36bc2328a013"));
        roomMap.put("23820279",Lists.newArrayList("1-16-1626","Sp3301100002a18a7dffe9c64fefb91e06c4e5c3bd72"));
        roomMap.put("23820278",Lists.newArrayList("1-16-1625","Sp3301100002a0a3764119d0428880397f78db8e5ce3"));
        roomMap.put("23820277",Lists.newArrayList("1-16-1623","Sp33011000029b1c670029b24e95b0793c277f091956"));
        roomMap.put("23820276",Lists.newArrayList("1-16-1622","Sp33011000028baff4fefb7e459d823204fdcf4aaf43"));
        roomMap.put("23820274",Lists.newArrayList("1-16-1620","Sp33011000026f2aa4327d9d4bd0a3455de0c3e9edd7"));
        roomMap.put("23820273",Lists.newArrayList("1-16-1619","Sp330110000262b75aeed2c14f6d85810e4159d61d14"));
        roomMap.put("23820271",Lists.newArrayList("1-16-1617","Sp33011000024e7d707c3a984229824f5b8d5f20ff8c"));
        roomMap.put("23820268",Lists.newArrayList("1-16-1613","Sp33011000023da5df2bc1bb41dd93458e68755ea5eb"));
        roomMap.put("23820266",Lists.newArrayList("1-16-1611","Sp33011000022affc45c1c2e40c1982b84a01b4c0b92"));
        roomMap.put("23820265",Lists.newArrayList("1-16-1610","Sp330110000217d32320ff8843b7a6719d02a4c1b28f"));
        roomMap.put("23820263",Lists.newArrayList("1-16-1608","Sp33011000020222c9d2048e408fa290e07ca98e6687"));
        roomMap.put("23820262",Lists.newArrayList("1-16-1607","Sp33011000020176a7a1bddd40afb2fc8305f3841e32"));
        roomMap.put("23820260",Lists.newArrayList("1-16-1605","Sp3301100002665768b30b1e4b73a65a3f23fcc8f0a9"));
        roomMap.put("23820257",Lists.newArrayList("1-16-1601","Sp330110000223a964bf25bd451b84270dae0e12abd6"));
        roomMap.put("23820256",Lists.newArrayList("1-15-1526","Sp330110000283ab932926b345ba9cd84491a06f3de7"));
        roomMap.put("23820255",Lists.newArrayList("1-15-1525","Sp33011000028366b1a520384a09a30ad6f9643242aa"));
        roomMap.put("23820254",Lists.newArrayList("1-15-1523","Sp33011000027f061ca4090c4af6bbe21027dbe95c4f"));
        roomMap.put("23820252",Lists.newArrayList("1-15-1521","Sp33011000027aaa89e11ebe4109b938f60b6dccd9d8"));
        roomMap.put("23820246",Lists.newArrayList("1-15-1515","Sp330110000244a1bf1a91484b14b3a6a85a9ea60428"));
        roomMap.put("23820245",Lists.newArrayList("1-15-1513","Sp330110000243e94f760de9473eab2c0f37036b683d"));
        roomMap.put("23820243",Lists.newArrayList("1-15-1511","Sp3301100002286f14a1dc2a42e08fdd189e59785192"));
        roomMap.put("23820241",Lists.newArrayList("1-15-1509","Sp330110000207df2b4ddd614db89446830429e2b587"));
        roomMap.put("23820238",Lists.newArrayList("1-15-1506","Sp3301100002a285dfb5d6714f94990b6fa996b5d98a"));
        roomMap.put("23820237",Lists.newArrayList("1-15-1505","Sp3301100002935eb2b905214843b79b76139d02b702"));
        roomMap.put("23820236",Lists.newArrayList("1-15-1503","Sp33011000029189acfd4c2547739f0c42cdca4855fd"));
        roomMap.put("23820235",Lists.newArrayList("1-15-1502","Sp330110000284f560ed7a0440dea5cd25283d9ce61b"));
        roomMap.put("23820234",Lists.newArrayList("1-15-1501","Sp33011000023705d3d5d1ac43389b3ef90fed847e6e"));
        roomMap.put("23820233",Lists.newArrayList("1-14-1426","Sp33011000026ca9903c7b334f7a841cc4f39200830a"));
        roomMap.put("23820232",Lists.newArrayList("1-14-1425","Sp33011000025da207cd8e514915811ddd1f1170206e"));
        roomMap.put("23820231",Lists.newArrayList("1-14-1423","Sp33011000024fde77fb54484099a07207a28c267a96"));
        roomMap.put("23820229",Lists.newArrayList("1-14-1421","Sp330110000243971a36f9234f7bb83397ad6327c57c"));
        roomMap.put("23820228",Lists.newArrayList("1-14-1420","Sp3301100002433a60b83d3145c3bb9521e3619a19ed"));
        roomMap.put("23820225",Lists.newArrayList("1-14-1417","Sp3301100002263f13be3d2247e683aaefb6dbae5e4a"));
        roomMap.put("23820223",Lists.newArrayList("1-14-1415","Sp330110000218c2ab269a334980aca15017bcb877a8"));
        roomMap.put("23820222",Lists.newArrayList("1-14-1413","Sp3301100002128ebf3b2f77411c8147e7dc0499f58f"));
        roomMap.put("23820218",Lists.newArrayList("1-14-1409","Sp3301100002d56d0699a66345e4b865e67a183b1e70"));
        roomMap.put("23820215",Lists.newArrayList("1-14-1406","Sp33011000027de9fad7791a4454bbaff45ad73daeb7"));
        roomMap.put("23820214",Lists.newArrayList("1-14-1405","Sp3301100002782007180f7d4819b512570fbc207564"));
        roomMap.put("23820213",Lists.newArrayList("1-14-1403","Sp330110000232b8d891e36a4ca7a35de71228f92607"));
        roomMap.put("23820212",Lists.newArrayList("1-14-1402","Sp330110000225ffb21e82624aad8b6c141063e97e9a"));
        roomMap.put("23820211",Lists.newArrayList("1-14-1401","Sp330110000208b981a1e8b949579f9a4732c0f35e31"));
        roomMap.put("23820206",Lists.newArrayList("1-13-1328","Sp3301100002432db853f04d4c08a9428a0cdc024f99"));
        roomMap.put("23820205",Lists.newArrayList("1-13-1327","Sp330110000240b08fb6429c49a2b37b258aaca6688f"));
        roomMap.put("23820203",Lists.newArrayList("1-13-1325-1","Sp330110000235acd7dee5eb480c8e3a7ab65feed307"));
        roomMap.put("23820203",Lists.newArrayList("1-13-1325-2","Sp330110000235c239adff2d4de7b8a9014fe2e32f1e"));
        roomMap.put("23820200",Lists.newArrayList("1-13-1321","Sp330110000233d4dc1e56e84ea4a7d7416e45e09c35"));
        roomMap.put("23820196",Lists.newArrayList("1-13-1317","Sp33011000021a25df863c3a487db5355986ee63cb00"));
        roomMap.put("23820195",Lists.newArrayList("1-13-1316","Sp3301100002199cab15dcaf4c7292749aeaf20033ff"));
        roomMap.put("23820194",Lists.newArrayList("1-13-1315","Sp33011000020c4aa2d06db54d63b4e73c9d2f11591a"));
        roomMap.put("23820193",Lists.newArrayList("1-13-1313","Sp33011000020a6b221f23ed4df29f268f4e2a4e4abf"));
        roomMap.put("23820186",Lists.newArrayList("1-13-1306","Sp33011000029f42c9da56814064af6fad49d98645cc"));
        roomMap.put("23820185",Lists.newArrayList("1-13-1305","Sp330110000280adff4e90f64026b234891aec671858"));
        roomMap.put("23820184",Lists.newArrayList("1-13-1303","Sp330110000257936d95f6b44f23a1a33bed90172f65"));
        roomMap.put("23820183",Lists.newArrayList("1-13-1302","Sp33011000024b283df8b2f64d6f8b92c1b66c04ea87"));
        roomMap.put("23820182",Lists.newArrayList("1-13-1301-1","Sp3301100002215425ca775e4d458447980f0f97a760"));
        roomMap.put("23820182",Lists.newArrayList("1-13-1301-2","Sp33011000023239a1878a1e4876aee87c9cd461b70b"));
        roomMap.put("23820173",Lists.newArrayList("1-12-1223","Sp3301100002aba1bd73324c48e8ac5ec14f5b979329"));
        roomMap.put("23820171",Lists.newArrayList("1-12-1221","Sp3301100002a3594ed3fe214cf09b53f68269b40aff"));
        roomMap.put("23820167",Lists.newArrayList("1-12-1217","Sp33011000028ec5216301914fed96a008a4066e8555"));
        roomMap.put("23820160",Lists.newArrayList("1-12-1209","Sp33011000024a851be20caf43feb4231a047b732808"));
        roomMap.put("23820156",Lists.newArrayList("1-12-1205","Sp33011000027b7c5d7875324f87a2d894065a9552cf"));
        roomMap.put("23820155",Lists.newArrayList("1-12-1203","Sp330110000243ca4f5398484095a96738273c024278"));
        roomMap.put("23820154",Lists.newArrayList("1-12-1202","Sp33011000023b2f31e15bfc4fd4abd3502d692a0795"));
        roomMap.put("23820153",Lists.newArrayList("1-12-1201-1","Sp330110000211bb717cf8e944e4aa44a745bcc597fb"));
        roomMap.put("23820153",Lists.newArrayList("1-12-1201-2","Sp3301100002175d1db99d064c4b9e22ed2b161c80ce"));
        roomMap.put("23820145",Lists.newArrayList("1-11-1125-1","Sp33011000025e23ebeb669040c6b1c6df19aab6e5f3"));
        roomMap.put("23820145",Lists.newArrayList("1-11-1125-2","Sp33011000025e34fa77886a4023a78f98bf07555609"));
        roomMap.put("23820136",Lists.newArrayList("1-11-1115","Sp330110000230fa4803a99b44f5af2a3caef0ad774a"));
        roomMap.put("23820081",Lists.newArrayList("1-1F-108","Sp3301100002762001f5ba4746eb806d0c3545f9e698"));

    }

    @Override
    public void open(Configuration parameters) throws Exception {
        System.out.println("初始化映射关系 ...... ");
        initMap();

        System.out.println("初始化MySQL数据库 ...... ");
        conn = DriverManager.getConnection(SysConstant.ZJ_MYSQL_URL, SysConstant.ZJ_MYSQL_USER, SysConstant.ZJ_MYSQL_PASSWD);
        ps = conn.prepareStatement("insert into permanent_space_zj (room_id, room_name, user_id, building_id, building_name, floor_id, floor_name, sp_id, sp_name)\n" +
                "values (?, ?, ?, ?, ?, ?, ?, ?, ?);");
    }

    @Override
    public void invoke(JSONArray value, Context context) throws Exception {

        if (value.size() != 0){
            List<UserToSpace> userToSpaces = value.toJavaList(UserToSpace.class);

            for (UserToSpace userToSpace : userToSpaces) {
                String[] ids = userToSpace.getUser_ids().split(",");
//                 && "23819976".equals(userToSpace.getBuilding_id()) && "23819981".equals(userToSpace.getFloor_id())
                if (ids.length != 0){
                    for (String id : ids) {
                        if (userIds.contains(id)) {
                            continue;
                        }
                        String room_id = userToSpace.getRoom_id();
                        if (roomMap.get(room_id) == null){
                            System.out.println("新空间ID插入 ：" + userToSpace.getRoom_id());
                            continue;
                        }
                        ps.setString(1, userToSpace.getRoom_id());
                        ps.setString(2, userToSpace.getRoom_name());
                        ps.setString(3, id);
                        ps.setString(4, userToSpace.getBuilding_id());
                        ps.setString(5, userToSpace.getBuilding_name());
                        ps.setString(6, userToSpace.getFloor_id());
                        ps.setString(7, userToSpace.getFloor_name());
                        ps.setString(8, roomMap.get(userToSpace.getRoom_id()).get(1));
                        ps.setString(9, roomMap.get(userToSpace.getRoom_id()).get(0));
                        ps.execute();
                        userIds.add(id);
                    }
                }
            }
        }
    }

    @Override
    public void close() throws Exception {
        ps.close();
        conn.close();
    }
}
